# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=man-pages
pkgver=6.05.01
pkgrel=0
pkgdesc="Linux man pages"
url="https://www.kernel.org/doc/man-pages/"
arch="noarch"
license="GPL-2.0-or-later"
source="https://cdn.kernel.org/pub/linux/docs/man-pages/man-pages-$pkgver.tar.xz
	no-install-T.patch
	"
# just manpages
options="!check"

package() {
	make LINK_PAGES=symlink SHELL=/bin/sh prefix="$pkgdir"/usr install
	# skip things already zipped- find can iterate over new files made by -exec
	find "$pkgdir"/usr/share/man -type f \
		! -name "*.gz" \
		-exec gzip -9 {} \+

	# the symlink install links to non-gzipped
	# installing with pre-gzipped form requires 'sponge'
	find "$pkgdir"/usr/share/man \( -type l -a ! -name "*.gz" \) -print0 | while IFS= read -r -d '' link; do
		# append gz since gzipped
		local target="$(readlink "$link")".gz

		rm "$link"
		ln -sfv "$target" "$link".gz
	done

	# provided by gnu-libiconv-doc
	rm -f "$pkgdir"/usr/share/man/man1/iconv*
	rm -f "$pkgdir"/usr/share/man/man3/iconv*

	# provided by mandoc
	rm -f "$pkgdir"/usr/share/man/man7/man* \
		"$pkgdir"/usr/share/man/man7/mdoc*

	# provided by tzdata
	rm -f "$pkgdir"/usr/share/man/man5/tzfile* \
		"$pkgdir"/usr/share/man/man8/tzselect* \
		"$pkgdir"/usr/share/man/man8/zic* \
		"$pkgdir"/usr/share/man/man8/zdump*
}

sha512sums="
ad3f6dc28bb83824faf8c855a5db8983dc0f5ac3b5702624033ed320a6f39a7f1f0845acf0bc62a0a10cdfe42eb66ba9596e2796ba2683cfb29e480710da3d70  man-pages-6.05.01.tar.xz
93ddb6de92af9b76aed1dc38f33e1b6d86ee2a03f49bdeab098d8075d9e8834bce31cce9e31595bea8b16499be6a9cb599b66b541d08895cb7c3c0cda354a70b  no-install-T.patch
"
